package io.renren.modules.sys.service.impl;

import io.renren.common.utils.Constant;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.FyClassPhotoDao;
import io.renren.modules.sys.entity.FyClassPhotoEntity;
import io.renren.modules.sys.service.FyClassPhotoService;


@Service("fyClassPhotoService")
public class FyClassPhotoServiceImpl extends ServiceImpl<FyClassPhotoDao, FyClassPhotoEntity> implements FyClassPhotoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String photoid = (String)params.get("photoid");

        IPage<FyClassPhotoEntity> page = null;
        if(StringUtils.isNotBlank(photoid)){
            page = this.page(
                    new Query<FyClassPhotoEntity>().getPage(params),
                    new QueryWrapper<FyClassPhotoEntity>().eq(StringUtils.isNotBlank(photoid),"photo_id",Integer.parseInt(photoid))
                            .apply(params.get(Constant.SQL_FILTER) != null, (String)params.get(Constant.SQL_FILTER))
            );
        }else{
            page = this.page(
                    new Query<FyClassPhotoEntity>().getPage(params),
                    new QueryWrapper<FyClassPhotoEntity>()
            );
        }


        return new PageUtils(page);
    }

}
